<%-- 
    Document   : Employee
    Created on : May 9, 2012, 9:28:43 AM
    Author     : Nguyen Hung
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<html>
    <head>
        <script type="text/javascript" language="javascript" src="../scripts/jQuery/jq.date.js"></script>   
        <!--        <script type="text/javascript" language="javascript" src="../scripts/jQuery/jquery-1.7.2.min.js"></script>      -->
        <link rel="stylesheet" type="text/css" href="../css/ui.datepicker.css"/>
        <link rel="stylesheet" type="text/css" href="../css/richTable.css"/>
        <style type="text/css">
            .addDisplay{
                display: block;
            }
            .removeDisplay{
                display: none;
            }
            
            .table_subheadercell{
                background: none repeat scroll 0 0 #488DB8;
            }
            .add_new_pro{
                width: 788px !important;
                background: #E6E9EB;
            }
            .stt{
                font-size: 12px;
            }
        </style>

        <script type="text/javascript" language="javascript">
            var open_cur = 0;
            $j = jQuery.noConflict();
            
            $j(document).ready(function(){ 
                //                
            });
            
        </script>


    </head>

    <f:view>
        <body>
            <f:loadBundle basename="#{environmentSession.localizationSource}" var="locale"/>            
            <div class="s100Content"> 
                <table>
                    <tr class="table_thead" id="table_header">
                        <td class="table_subheadercell " style="width: 110px">
                            <h:outputText value="Chu kì" escape="false"/>
                        </td>
                        <td class="table_subheadercell " style="width: 110px">
                            <h:outputText value="Thứ" escape="false"/>
                        </td>
                        <td class="table_subheadercell " style="width: 120px ">
                            <h:outputText value="Ngày" />
                        </td>
                        <td class="table_subheadercell " style="width: 80px">
                            <h:outputText value="Khởi hành" escape="false"/>
                        </td>
                        <td class="table_subheadercell " style="width: 80px">
                            <h:outputText value="Giờ đên" />
                        </td>
                        <td class="table_subheadercell " style="width: 180px">
                            <h:outputText value="Chuyến bay" />
                        </td>
                        <td class="table_subheadercell " style="width: 57px">
                            <h:outputText value="Chức năng" />
                        </td>
                    </tr>
                </table>
                <table class="table_content">
                    <a4j:repeat value="#{SPBean.listS100}" var="s100" rowKeyVar="row" >
                        <tr class="action_product" lang="<h:outputText value="#{SPBean.fs400}" />" style="background:<h:outputText rendered="#{row%2!=0}" value="#E0EFFC"/>" >
                            <td>
                                <div><h:outputText styleClass="stt" value="#{row+1}"/></div>
                            </td>
                            <td class="div_select">
                                <span>  <h:outputText rendered="#{s100.sn104 == 1}" value="Hàng Tuần"/>
                                    <h:outputText rendered="#{s100.sn104 == 0}" value="1 lần"/>
                                    <h:outputText rendered="#{s100.sn104 ==2}" value="Hàng Tháng"/></span>  
                            </td>

                            <td class="div_select selectSN107"> 
                                <span class="abc123 <h:outputText rendered="#{s100.sn104 == 2 || s100.sn104 == 0}" value="removeDisplay"/>">  
                                    <h:outputText rendered="#{s100.sn101 == 1}" value="Chủ nhật"/>
                                    <h:outputText rendered="#{s100.sn101 == 2}" value="Thứ Hai"/>
                                    <h:outputText rendered="#{s100.sn101 == 3}" value="Thứ Ba"/>
                                    <h:outputText rendered="#{s100.sn101 == 4}" value="Thứ Tư"/>
                                    <h:outputText rendered="#{s100.sn101 == 5}" value="Thứ Năm"/>
                                    <h:outputText rendered="#{s100.sn101 == 6}" value="Thứ Sáu"/>
                                    <h:outputText rendered="#{s100.sn101 == 7}" value="Thứ Bảy"/>
                                </span>  
                            </td>

                            <td class="action_date" >   
                                <div class="action_d <h:outputText rendered="#{s100.sn104 == 1}" value="removeDisplay"/>">
                                    <span>  
                                        <h:outputText value="#{s100.date_rep}"> <f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>
                                        </span>  
                                    </div>
                                </td>

                                <td class="action_time">
                                <%-- gio phut --%>

                                <h:outputText value="#{s100.sn102}:#{s100.sn103}" styleClass="number sn102"><f:convertNumber pattern="##" type="number"/> </h:outputText>


                                </td>
                                <td class="action_time">


                                <h:outputText value="#{s100.sn108}:#{s100.sn109}" styleClass="number sn108"><f:convertNumber pattern="##" type="number"/> </h:outputText>

                                </td>

                                <td class="action_airline">                                
                                <h:outputText value="#{s100.sv110}" styleClass="sv110"></h:outputText>
                                </td>
                                <td class="div_addS100"> 
                                <h:inputHidden value="#{SPBean.fs400}" id="ps400"/>
                                <h:inputHidden value="#{s100.ps100}" id="ps100_"/>                                
                                <h:panelGroup rendered="#{loginSession.right.TOU_TOUR_CRE}"> <img src="../images/edit.png" alt="Thêm" title="Thêm" class="editS100" id="<h:outputText value="#{s100.sn101}"/>" lang="fs400=<h:outputText value="#{SPBean.fs400}"/>&ps100=<h:outputText value="#{s100.ps100}"/>"/> </h:panelGroup>

                                <h:outputLink  rendered="#{loginSession.right.TOU_TCK_DEL}"   value="delete.jsp?id=#{s100.ps100}&id2=#{SPBean.fs400}&flag=S100&width=300&height=150" styleClass="fancybox">
                                    <img src="../images/sub_tab.png" alt="delete"  title="delete" />
                                </h:outputLink> 


                            </td>    

                        </tr>
                        <tr class="action_product removeDisplay" lang="<h:outputText value="#{SPBean.fs400}" />" style="background:<h:outputText rendered="#{row%2!=0}" value="#E0EFFC"/>">
                            <td>
                                <div><h:outputText styleClass="stt" value="#{row+1}"/></div>
                            </td>
                            <td class="div_select">
                                <h:selectOneMenu value="#{s100.sn104}"  styleClass="cbx_select selectSN104 sn104">  
                                    <f:selectItem  itemValue="0" itemLabel="1 lần" />
                                    <f:selectItem itemValue="1" itemLabel="Hàng Tuần"/>
                                    <f:selectItem itemValue="2" itemLabel="Hàng Tháng"/>
                                </h:selectOneMenu>
                            </td>

                            <td class="div_select selectSN107">                            
                                <h:selectOneMenu value="#{s100.sn101}"  styleClass="cbx_select  sn101">  
                                    <%--  <f:selectItem  itemValue="0" itemLabel="#{locale.all}" /> --%>
                                    <f:selectItems value="#{SPBean.listday}" />
                                </h:selectOneMenu> 
                            </td>

                            <td class="action_date" >   
                                <div class="action_d <h:outputText rendered="#{s100.sn104 == 1}" value="removeDisplay"/>">
                                    <input type="text" id="dateRepeat<h:outputText value="#{row+1}"/>" name="dateRepeat<h:outputText value="#{row+1}"/>"  class="input_fields required date dateRepeat"  
                                           value="<h:outputText value="#{SPBean.repeat_date}"> <f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>"/>
                                    </div>
                                </td>

                                <td class="action_time">
                                <%-- gio phut --%>

                                <h:inputText value="#{s100.sn102}" styleClass="number sn102"><f:convertNumber pattern="##"/> </h:inputText>
                                    <label >:</label>   
                                <h:inputText value="#{s100.sn103}" styleClass="number sn103"><f:convertNumber pattern="##"/> </h:inputText>

                                </td>
                                <td class="action_time">


                                <h:inputText value="#{s100.sn108}" styleClass="number sn108"><f:convertNumber pattern="##"/> </h:inputText>
                                    <label >:</label>   
                                <h:inputText value="#{s100.sn109}" styleClass="number sn109"><f:convertNumber pattern="##"/> </h:inputText>
                                </td>

                                <td class="action_airline">                                
                                <h:inputText value="#{s100.sv110}" styleClass="sv110"></h:inputText>
                                </td>
                                <td class="div_addS100"> 
                                <h:inputHidden value="#{SPBean.fs400}" id="ps400_"/>
                                <h:inputHidden value="#{s100.ps100}" id="ps100_1"/>                                
                                <img src="../images/check_alt.png" alt="Thêm" title="Thêm" class="submitS1002" lang="fs400=<h:outputText value="#{SPBean.fs400}"/>&ps100=<h:outputText value="#{s100.ps100}"/>"/> 

                                <h:outputLink     value="delete.jsp?id=#{s100.ps100}&id2=#{SPBean.fs400}&flag=S100&width=300&height=150" styleClass="fancybox">
                                    <img src="../images/sub_tab.png" alt="delete"  title="delete" />
                                </h:outputLink> 


                            </td>    

                        </tr>
                    </a4j:repeat> 
                </table>
                <div class="s100">
                    <table id="s100_0" class="table_addNew">
                        <tr class="action_product add_new_pro" lang="<h:outputText value="#{SPBean.fs400}" />">
                            <td class="div_select">
                                <h:selectOneMenu value="#{SPBean.pnSN104}"  styleClass="cbx_select selectSN104 sn104" id="sn104">  
                                    <f:selectItem  itemValue="0" itemLabel="1 lần" />
                                    <f:selectItem itemValue="1" itemLabel="Hàng Tuần"/>
                                    <f:selectItem itemValue="2" itemLabel="Hàng Tháng"/>
                                </h:selectOneMenu>

                            </td>
                            <td class="div_select selectSN107">                               
                                <h:selectOneMenu value="#{SPBean.pnSN101}"  styleClass="cbx_select  sn101"> 

                                    <f:selectItems value="#{SPBean.listday}" />

                                </h:selectOneMenu> 
                            </td>

                            <td class="action_date">                                               
                                <div  class="action_d <h:outputText rendered="#{SPBean.pnSN104 == 1}" value="removeDisplay"/>" >
                                    <input d type="text" id="dateRepeat" name="dateRepeat"  class="input_fields required date dateRepeat"  
                                           value="<h:outputText value="#{SPBean.repeat_date}"> <f:convertDateTime pattern="dd/MM/yyyy"/></h:outputText>"/>
                                    </div>
                                </td>

                                <td class="action_time">
                                <%-- gio phut --%>                                    
                                <h:inputText value="#{SPBean.pnSN102}" styleClass="number sn102"><f:convertNumber pattern="##"/> </h:inputText>
                                    <label >:</label>   
                                <h:inputText value="#{SPBean.pnSN103}" styleClass="number sn103"><f:convertNumber pattern="##"/> </h:inputText>

                                </td>
                                <td class="action_time padding_time">

                                <h:inputText value="#{SPBean.pnCN108}" styleClass="number sn108"><f:convertNumber pattern="##"/> </h:inputText>
                                    <label >:</label>   
                                <h:inputText value="#{SPBean.pnCN109}" styleClass="number sn109"><f:convertNumber pattern="##"/> </h:inputText>
                                </td>
                                <td class="action_airline">                                   
                                    <h:inputText value="#{SPBean.pvSV110}" styleClass="sv110"></h:inputText>
                                </td>

                                <td class="div_addS100">                                

                                <%--   <h:commandButton  action="#{SPBean.updateS100}" styleClass="buttonsaveS100">
                                       <f:param value="#{SPBean.fs400}" name="fs400"/>
                                       <f:param value="#{SPBean.ps100}" name="ps100"/>
                                       <f:param value="1" name="flag"/>

                                </h:commandButton>      --%>                          
                                <h:inputHidden value="#{SPBean.fs400}" id="ps400_0"/>
                                <%--    <img src="../images/check_alt.png" alt="Thêm" title="Thêm" class="submitS100" lang="fs400=<h:outputText value="#{SPBean.fs400}"/>&ps100=0"/>                            
                                --%>
                                <h:panelGroup rendered="#{loginSession.right.TOU_TOUR_CRE}">  <img src="../images/add_tab.png" alt="Thêm" title="Thêm" class="submitS100" lang="fs400=<h:outputText value="#{SPBean.fs400}"/>&ps100=0"/> </h:panelGroup>


                                </td>
                            </tr> 
                        </table>

                    </div>       


                </div>


            </body>
    </f:view>
</html>
<script type="text/javascript" language="javascript">
    var open_cur = 0;
    $j = jQuery.noConflict();
            
    $j(document).ready(function(){      
                
        $j('input#dateRepeat').datepicker({ dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '../images/calenda_icon.gif', buttonImageOnly: true });
         
     
        $j('.editS100').live('click',function(){
            var iddate = $j(this).parent().prev().prev().prev().prev().prev().prev().prev().children().children().text();
            //  alert($j(this).parent().prev().prev().prev().prev().prev().prev().text().trim());
            var nameday = $j(this).parent().prev().prev().prev().prev().prev().prev().text();
           // alert(nameday.length);
            var numberday = nameday.length;
            // alert(numberday)
            // var namday1 = nameday.
            
            
            
      
            $j('input#dateRepeat'+iddate).datepicker({ dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '../images/calenda_icon.gif', buttonImageOnly: true });
            var s100 =  $j(this).parent().parent(); 
            var s100id = $j(this).attr('id');
            var s100value="";
            switch (s100id) {
                case '1':
                    s100value="Chủ nhật";
                    break;
                case '2':
                    s100value="Thứ Hai";
                    break;
                case '3':
                    s100value="Thứ Ba";
                    break;
                case '4':
                    s100value="Thứ Tư";
                    break;
                case '5':
                    s100value="Thứ Năm";
                    break;
                case '6':
                    s100value="Thứ Sáu";
                    break;
                case '7':
                    s100value="Thứ Bảy";
                    break;
            }
            s100.addClass('removeDisplay');
            s100.removeClass('addDisplay');
            
            var s100_2 =  $j(this).parent().parent().next();  
            s100_2.addClass('addDisplay');
            s100_2.removeClass('removeDisplay');
            if(numberday == 145 ){
              //  alert("alo");
                 $j(this).parent().parent().next().find('.selectSN107').children().addClass('removeDisplay');
               //.css("disabled","true");
             //   $j(this).parent().parent().next().find('.action_date').addClass('widthclass');
            }else if(numberday == 149){
                 $j(this).parent().parent().next().find('.action_date').children().addClass("removeDisplay");
            }else{
                 $j(this).parent().parent().next().find('.selectSN107').children().addClass('removeDisplay');
            }
            var s100edit= $j(this).parent().parent().next().find('.selectSN107').find('.sn101'); 
            //alert(s100edit.attr('class'));
            var i='Y';
            if(s100edit.children('option:selected').val()==s100id)
            {
                i='N'
            }

            if(i=='Y'){
                var str = '<option selected="selected" value="'+s100id+'">'+s100value+'</option>';
                s100edit.append(str);
            }
            
            
            
        });
        $j('.selectSN104').live("change",function(){                                        
            var date =  $j(this).parent().parent().find('.action_d');  
           
            var day = $j(this).parent().next().find('.sn101');
            var sn104 = $j(this).val();            
            if(sn104 == 2 || sn104 == 0){                
                date.addClass('addDisplay');
                date.removeClass('removeDisplay');
                day.addClass('removeDisplay');
                day.removeClass('addDisplay');
                
            }else{
                date.addClass('removeDisplay');
                date.removeClass('addDisplay');
                day.addClass('addDisplay');
                day.removeClass('removeDisplay');
            }
            
                       
        });
        $j('.submitS100').live('click',function(){
            
            ps100 = $j(this).attr('lang');
            //            alert('ps100: '+ps100);
            var s100 = $j(this).parent().parent();
            sn101 =  s100.find('.sn101').val();
         //   alert(sn101);
            sn102 =  s100.find('.sn102').val();
            sn103 =  s100.find('.sn103').val();
            sn104 =  s100.find('.sn104').val();
            date = s100.find('.dateRepeat').val();
            sn108 =  s100.find('.sn108').val();
            sn109 =  s100.find('.sn109').val();
            sv110 =  s100.find('.sv110').val();
            fs400 = s100.attr('lang');
            //            alert('fs400: '+ fs400);
            //            alert('submitS100--'+ps100+"--sn101-"+sn101+"-sn102-"+sn102+"-sn103-"+sn103+"-sn104-"+sn104+"-date-"+date+"---sn108-"+sn108+"-sn109-"+sn109+"-sv110-"+sv110);
            $j.post("actionS100.jsp?action=addS100&"+ps100+"&sn101="+sn101+"&sn102="+sn102+"&sn103="+sn103+"&sn104="+sn104+"&date="+date+"&sn108="+sn108+"&sn109="+sn109+"&sv110="+sv110,function(data){
                if(data !=null){
                    window.location.href="createProduct.jsp?tab=s100"+fs400;        
                }
            });
        });
        $j('.submitS1002').live('click',function(){
            //var iddate = $j(this).parent().prev().prev().prev().prev().prev().prev().prev().children().children().text();
            date = $j(this).parent().prev().prev().prev().prev().children().children().val();
            ps100 = $j(this).attr('lang');
            //            alert('ps100: '+ps100);
            var s100 = $j(this).parent().parent();
            sn101 =  s100.find('.sn101').val();
            sn102 =  s100.find('.sn102').val();
            sn103 =  s100.find('.sn103').val();
            sn104 =  s100.find('.sn104').val();
            //  date = s100.find('.dateRepeat3').val();
            //   alert(date);
            sn108 =  s100.find('.sn108').val();
            sn109 =  s100.find('.sn109').val();
            sv110 =  s100.find('.sv110').val();
            fs400 = s100.attr('lang');
            //            alert('fs400: '+ fs400);
            //            alert('submitS100--'+ps100+"--sn101-"+sn101+"-sn102-"+sn102+"-sn103-"+sn103+"-sn104-"+sn104+"-date-"+date+"---sn108-"+sn108+"-sn109-"+sn109+"-sv110-"+sv110);
            $j.post("actionS100.jsp?action=addS100&"+ps100+"&sn101="+sn101+"&sn102="+sn102+"&sn103="+sn103+"&sn104="+sn104+"&date="+date+"&sn108="+sn108+"&sn109="+sn109+"&sv110="+sv110,function(data){
                if(data !=null){
                    window.location.href="createProduct.jsp?tab=s100"+fs400;        
                }
            });
        });
    });
</script>